﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCCommon;
using System.Text;
using System.Net;
using Microsoft.AspNetCore.Mvc;
using BCDto.TMS.WorryFreeMoveSuiteConfigTemplate;
using BCTMSRESTful.Configs;
using BCService.Utils;
using BCService.TMS.WorryFreeMoveSuiteConfigTemplate;

namespace BCTMSRESTful.Controllers.Management.TMS.WorryFreeMoveSuiteConfigTemplate
{
    /// <summary>
    /// 无忧搬家套餐配置模板
    /// </summary>
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class WorryFreeMoveSuiteConfigTemplateController : ManagementBaseController
    {
        private readonly IWorryFreeMoveSuiteConfigTemplateService worryFreeMoveSuiteConfigTemplateService;

        public WorryFreeMoveSuiteConfigTemplateController(IWorryFreeMoveSuiteConfigTemplateService worryFreeMoveSuiteConfigTemplateService)
        {
            this.worryFreeMoveSuiteConfigTemplateService = worryFreeMoveSuiteConfigTemplateService;
        }

        #region 添加无忧搬家套餐配置模板
        /// <summary>
        ///  添加无忧搬家套餐配置模板
        /// </summary>
        /// <param name="requestDto">无忧搬家套餐配置模板信息</param>
        /// <response code="201">添加无忧搬家套餐配置模板成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPost]
        [Log("添加无忧搬家套餐配置模板")]
        [ProducesResponseType(typeof(WorryFreeMoveSuiteConfigTemplateDto), 201)]
        public IActionResult Post(
            [FromBody] WorryFreeMoveSuiteConfigTemplateRequestDto requestDto)
        {
            var result = this.worryFreeMoveSuiteConfigTemplateService.Add(this.Admin,requestDto);
            return StatusCode((int)HttpStatusCode.Created, result);
        }
        #endregion

        #region 修改无忧搬家套餐配置模板
        /// <summary>
        ///  修改无忧搬家套餐配置模板
        /// </summary>
        /// <param name="worryFreeMoveSuiteConfigTemplateId">无忧搬家套餐配置模板Id</param>
        /// <param name="requestDto">无忧搬家套餐配置模板信息</param>
        /// <response code="200">修改无忧搬家套餐配置模板成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPut("{worry_free_move_suite_config_template_id}")]
        [Log("修改无忧搬家套餐配置模板")]
        [ProducesResponseType(typeof(WorryFreeMoveSuiteConfigTemplateDto), 200)]
        public IActionResult Put([FromRoute(Name = "worry_free_move_suite_config_template_id")] int worryFreeMoveSuiteConfigTemplateId, [FromBody] WorryFreeMoveSuiteConfigTemplateRequestDto requestDto)
        {
            WorryFreeMoveSuiteConfigTemplatePutDto putDto = requestDto.As<WorryFreeMoveSuiteConfigTemplatePutDto>();
            putDto.WorryFreeMoveSuiteConfigTemplateId = worryFreeMoveSuiteConfigTemplateId;
            return StatusCode((int)HttpStatusCode.OK, this.worryFreeMoveSuiteConfigTemplateService.Update(this.Admin, putDto));
        }
        #endregion

        #region 删除无忧搬家套餐配置模板
        /// <summary>
        ///  删除无忧搬家套餐配置模板
        /// </summary>
        /// <param name="worryFreeMoveSuiteConfigTemplateId">无忧搬家套餐配置模板Id</param>
        /// <response code="204">删除无忧搬家套餐配置模板成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpDelete("{worry_free_move_suite_config_template_id}")]
        [Log("删除无忧搬家套餐配置模板")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Delete([FromRoute(Name = "worry_free_move_suite_config_template_id")] int worryFreeMoveSuiteConfigTemplateId)
        {
            this.worryFreeMoveSuiteConfigTemplateService.Delete(worryFreeMoveSuiteConfigTemplateId);
            return StatusCode((int)HttpStatusCode.NoContent);
        }
        #endregion

        #region 获取无忧搬家套餐配置模板
        /// <summary>
        ///  获取无忧搬家套餐配置模板
        /// </summary>
        /// <param name="worryFreeMoveSuiteConfigTemplateId">无忧搬家套餐配置模板Id</param>
        /// <response code="200">获取无忧搬家套餐配置模板</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("{worry_free_move_suite_config_template_id}")]
        [ProducesResponseType(typeof(WorryFreeMoveSuiteConfigTemplateDto), 200)]
        public IActionResult Get([FromRoute(Name = "worry_free_move_suite_config_template_id")] int worryFreeMoveSuiteConfigTemplateId)
        {
            return StatusCode((int)HttpStatusCode.OK, this.worryFreeMoveSuiteConfigTemplateService.Get(worryFreeMoveSuiteConfigTemplateId));
        }
        #endregion

        #region 获取无忧搬家套餐配置模板列表
        /// <summary>
        ///  获取无忧搬家套餐配置模板列表
        /// </summary>
        /// <response code="200">获取无忧搬家套餐配置模板列表</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(WorryFreeMoveSuiteConfigTemplateDto), 200)]
        public IActionResult Get()
        {
            return StatusCode((int)HttpStatusCode.OK, this.worryFreeMoveSuiteConfigTemplateService.GetList());
        }
        #endregion

        #region 获取无忧搬家套餐配置模板（分页）
        /// <summary>
        ///  获取无忧搬家套餐配置模板（分页）
        /// </summary>
        /// <param name="suiteName">套餐名称</param>
        /// <param name="enabled">是否启用</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="ascending">升序</param>
        /// <param name="index">当前页码</param>
        /// <param name="size">当前页大小</param>
        /// <response code="200">获取无忧搬家套餐配置模板（分页）</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<WorryFreeMoveSuiteConfigTemplateDto>), 200)]
        public IActionResult Query(
            [FromQuery(Name = "suite_name")] string suiteName,
            [FromQuery(Name = "enabled")] bool? enabled,
            [FromQuery(Name = "start")] DateTime? start,
            [FromQuery(Name = "end")] DateTime? end,
            [FromQuery(Name = "sort_name")] string sortName,
            [FromQuery(Name = "ascending")] bool? ascending,
            [FromQuery(Name = "index")] int index = 1,
            [FromQuery(Name = "size")] int size = 10)
        {
            return StatusCode((int)HttpStatusCode.OK, this.worryFreeMoveSuiteConfigTemplateService.Query(suiteName, enabled, start, end, sortName, ascending, index, size));
        }
        #endregion

        #region 启用/禁用无忧搬家套餐配置模板
        /// <summary>
        ///  启用/禁用无忧搬家套餐配置模板
        /// </summary>
        /// <param name="worryFreeMoveSuiteConfigTemplateId">无忧搬家套餐配置模板Id</param>
        /// <param name="enabled">是否启用</param>
        /// <response code="204">启用/禁用无忧搬家套餐配置模板成功</response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPut("[action]/{worry_free_move_suite_config_template_id}/{enabled}")]
        [Log("启用/禁用无忧搬家套餐配置模板")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Enabled([FromRoute(Name = "worry_free_move_suite_config_template_id")] int worryFreeMoveSuiteConfigTemplateId,
            [FromRoute(Name = "enabled")] bool enabled)
        {
            if (enabled)
            {
                this.worryFreeMoveSuiteConfigTemplateService.Enabled(this.Admin,worryFreeMoveSuiteConfigTemplateId);
                return StatusCode((int)HttpStatusCode.NoContent);
            }
            else
            {
                this.worryFreeMoveSuiteConfigTemplateService.Disabled(this.Admin,worryFreeMoveSuiteConfigTemplateId);
                return StatusCode((int)HttpStatusCode.NoContent);
            }
        }
        #endregion
    }
}

